package com.dgut.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.dgut.common.model.entity.Goods;
import com.dgut.common.util.SystemJsonResponse;
import com.dgut.service.GoodsService;

/**
 * @author huangyujia <huangyujia@kuaishou.com>
 * Created on 2024-06-18
 * 商品模块
 */
@RestController()
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @GetMapping("list")
    public SystemJsonResponse getGoodsList() {
        return goodsService.getGoodsList();
    }

    @PostMapping("/add")
    public SystemJsonResponse addGoods(@RequestBody Goods goods) {
        return goodsService.addGoods(goods);
    }

    @PostMapping("/delete")
    public SystemJsonResponse deleteGoods(@RequestParam String id) {
        return goodsService.deleteGoods(id);
    }

    @PostMapping("/update")
    public SystemJsonResponse updateGoods(@RequestBody Goods goods) {
        return goodsService.updateGoods(goods);
    }
}
